.class Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;
.super Ljava/lang/Object;
.source "NioDatagramWorker.java"

# interfaces
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker$ChannelRegistionTask;
    }
.end annotation


# static fields
.field static final synthetic $assertionsDisabled:Z

.field private static final logger:Lorg/jboss/netty/logging/InternalLogger;


# instance fields
.field private final bossId:I

.field private volatile cancelledKeys:I

.field private final executor:Ljava/util/concurrent/Executor;

.field private final id:I

.field private final registerTaskQueue:Ljava/util/Queue;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Queue",
            "<",
            "Ljava/lang/Runnable;",
            ">;"
        }
    .end annotation
.end field

.field volatile selector:Ljava/nio/channels/Selector;

.field private final selectorGuard:Ljava/util/concurrent/locks/ReadWriteLock;

.field private final sendBufferPool:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool;

.field private final startStopLock:Ljava/lang/Object;

.field private started:Z

.field private volatile thread:Ljava/lang/Thread;

.field private final wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

.field private final writeTaskQueue:Ljava/util/Queue;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Queue",
            "<",
            "Ljava/lang/Runnable;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 55
    const-class v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;

    invoke-virtual {v0}, Ljava/lang/Class;->desiredAssertionStatus()Z

    move-result v0

    if-nez v0, :cond_0

    const/4 v0, 0x1

    :goto_0
    sput-boolean v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->$assertionsDisabled:Z

    .line 59
    const-class v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;

    invoke-static {v0}, Lorg/jboss/netty/logging/InternalLoggerFactory;->getInstance(Ljava/lang/Class;)Lorg/jboss/netty/logging/InternalLogger;

    move-result-object v0

    sput-object v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->logger:Lorg/jboss/netty/logging/InternalLogger;

    return-void

    .line 55
    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method constructor <init>(IILjava/util/concurrent/Executor;)V
    .locals 1
    .parameter "bossId"
    .parameter "id"
    .parameter "executor"

    .prologue
    .line 134
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 100
    new-instance v0, Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    .line 105
    new-instance v0, Ljava/util/concurrent/locks/ReentrantReadWriteLock;

    invoke-direct {v0}, Ljava/util/concurrent/locks/ReentrantReadWriteLock;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selectorGuard:Ljava/util/concurrent/locks/ReadWriteLock;

    .line 110
    new-instance v0, Ljava/lang/Object;

    invoke-direct {v0}, Ljava/lang/Object;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->startStopLock:Ljava/lang/Object;

    .line 115
    const-class v0, Ljava/lang/Runnable;

    invoke-static {v0}, Lorg/jboss/netty/util/internal/QueueFactory;->createQueue(Ljava/lang/Class;)Ljava/util/concurrent/BlockingQueue;

    move-result-object v0

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->registerTaskQueue:Ljava/util/Queue;

    .line 120
    const-class v0, Ljava/lang/Runnable;

    invoke-static {v0}, Lorg/jboss/netty/util/internal/QueueFactory;->createQueue(Ljava/lang/Class;)Ljava/util/concurrent/BlockingQueue;

    move-result-object v0

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->writeTaskQueue:Ljava/util/Queue;

    .line 124
    new-instance v0, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool;

    invoke-direct {v0}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool;-><init>()V

    iput-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->sendBufferPool:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool;

    .line 135
    iput p1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->bossId:I

    .line 136
    iput p2, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->id:I

    .line 137
    iput-object p3, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->executor:Ljava/util/concurrent/Executor;

    .line 138
    return-void
.end method

.method private cleanUpCancelledKeys()Z
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    const/4 v0, 0x0

    .line 361
    iget v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cancelledKeys:I

    const/16 v2, 0x100

    if-lt v1, v2, :cond_0

    .line 362
    iput v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cancelledKeys:I

    .line 363
    iget-object v0, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    invoke-virtual {v0}, Ljava/nio/channels/Selector;->selectNow()I

    .line 364
    const/4 v0, 0x1

    .line 366
    :cond_0
    return v0
.end method

.method private cleanUpWriteBuffer(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V
    .locals 8
    .parameter "channel"

    .prologue
    .line 686
    const/4 v0, 0x0

    .line 687
    .local v0, cause:Ljava/lang/Exception;
    const/4 v3, 0x0

    .line 690
    .local v3, fireExceptionCaught:Z
    iget-object v7, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeLock:Ljava/lang/Object;

    monitor-enter v7

    .line 691
    :try_start_0
    iget-object v2, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteEvent:Lorg/jboss/netty/channel/MessageEvent;

    .line 692
    .local v2, evt:Lorg/jboss/netty/channel/MessageEvent;
    if-eqz v2, :cond_6

    .line 695
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->isOpen()Z

    move-result v6

    if-eqz v6, :cond_1

    .line 696
    new-instance v1, Ljava/nio/channels/NotYetBoundException;

    invoke-direct {v1}, Ljava/nio/channels/NotYetBoundException;-><init>()V

    .end local v0           #cause:Ljava/lang/Exception;
    .local v1, cause:Ljava/lang/Exception;
    move-object v0, v1

    .line 701
    .end local v1           #cause:Ljava/lang/Exception;
    .restart local v0       #cause:Ljava/lang/Exception;
    :goto_0
    invoke-interface {v2}, Lorg/jboss/netty/channel/MessageEvent;->getFuture()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v4

    .line 702
    .local v4, future:Lorg/jboss/netty/channel/ChannelFuture;
    iget-object v6, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteBuffer:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;

    invoke-interface {v6}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;->release()V

    .line 703
    const/4 v6, 0x0

    iput-object v6, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteBuffer:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;

    .line 704
    const/4 v6, 0x0

    iput-object v6, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteEvent:Lorg/jboss/netty/channel/MessageEvent;

    .line 705
    const/4 v2, 0x0

    .line 706
    invoke-interface {v4, v0}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 707
    const/4 v3, 0x1

    move-object v1, v0

    .line 710
    .end local v0           #cause:Ljava/lang/Exception;
    .end local v4           #future:Lorg/jboss/netty/channel/ChannelFuture;
    .restart local v1       #cause:Ljava/lang/Exception;
    :goto_1
    :try_start_1
    iget-object v5, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeBufferQueue:Ljava/util/Queue;

    .line 711
    .local v5, writeBuffer:Ljava/util/Queue;,"Ljava/util/Queue<Lorg/jboss/netty/channel/MessageEvent;>;"
    invoke-interface {v5}, Ljava/util/Queue;->isEmpty()Z

    move-result v6

    if-nez v6, :cond_5

    .line 714
    if-nez v1, :cond_4

    .line 715
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->isOpen()Z

    move-result v6

    if-eqz v6, :cond_2

    .line 716
    new-instance v0, Ljava/nio/channels/NotYetBoundException;

    invoke-direct {v0}, Ljava/nio/channels/NotYetBoundException;-><init>()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    .line 723
    .end local v1           #cause:Ljava/lang/Exception;
    .restart local v0       #cause:Ljava/lang/Exception;
    :goto_2
    :try_start_2
    invoke-interface {v5}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    move-result-object v2

    .end local v2           #evt:Lorg/jboss/netty/channel/MessageEvent;
    check-cast v2, Lorg/jboss/netty/channel/MessageEvent;

    .line 724
    .restart local v2       #evt:Lorg/jboss/netty/channel/MessageEvent;
    if-nez v2, :cond_3

    .line 731
    :goto_3
    monitor-exit v7
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    .line 733
    if-eqz v3, :cond_0

    .line 734
    invoke-static {p1, v0}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    .line 736
    :cond_0
    return-void

    .line 698
    .end local v5           #writeBuffer:Ljava/util/Queue;,"Ljava/util/Queue<Lorg/jboss/netty/channel/MessageEvent;>;"
    :cond_1
    :try_start_3
    new-instance v1, Ljava/nio/channels/ClosedChannelException;

    invoke-direct {v1}, Ljava/nio/channels/ClosedChannelException;-><init>()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .end local v0           #cause:Ljava/lang/Exception;
    .restart local v1       #cause:Ljava/lang/Exception;
    move-object v0, v1

    .end local v1           #cause:Ljava/lang/Exception;
    .restart local v0       #cause:Ljava/lang/Exception;
    goto :goto_0

    .line 718
    .end local v0           #cause:Ljava/lang/Exception;
    .restart local v1       #cause:Ljava/lang/Exception;
    .restart local v5       #writeBuffer:Ljava/util/Queue;,"Ljava/util/Queue<Lorg/jboss/netty/channel/MessageEvent;>;"
    :cond_2
    :try_start_4
    new-instance v0, Ljava/nio/channels/ClosedChannelException;

    invoke-direct {v0}, Ljava/nio/channels/ClosedChannelException;-><init>()V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    .end local v1           #cause:Ljava/lang/Exception;
    .restart local v0       #cause:Ljava/lang/Exception;
    goto :goto_2

    .line 727
    :cond_3
    :try_start_5
    invoke-interface {v2}, Lorg/jboss/netty/channel/MessageEvent;->getFuture()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v6

    invoke-interface {v6, v0}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z

    .line 728
    const/4 v3, 0x1

    goto :goto_2

    .line 731
    .end local v2           #evt:Lorg/jboss/netty/channel/MessageEvent;
    .end local v5           #writeBuffer:Ljava/util/Queue;,"Ljava/util/Queue<Lorg/jboss/netty/channel/MessageEvent;>;"
    :catchall_0
    move-exception v6

    :goto_4
    monitor-exit v7
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    throw v6

    .end local v0           #cause:Ljava/lang/Exception;
    .restart local v1       #cause:Ljava/lang/Exception;
    .restart local v2       #evt:Lorg/jboss/netty/channel/MessageEvent;
    :catchall_1
    move-exception v6

    move-object v0, v1

    .end local v1           #cause:Ljava/lang/Exception;
    .restart local v0       #cause:Ljava/lang/Exception;
    goto :goto_4

    .end local v0           #cause:Ljava/lang/Exception;
    .restart local v1       #cause:Ljava/lang/Exception;
    .restart local v5       #writeBuffer:Ljava/util/Queue;,"Ljava/util/Queue<Lorg/jboss/netty/channel/MessageEvent;>;"
    :cond_4
    move-object v0, v1

    .end local v1           #cause:Ljava/lang/Exception;
    .restart local v0       #cause:Ljava/lang/Exception;
    goto :goto_2

    .end local v0           #cause:Ljava/lang/Exception;
    .restart local v1       #cause:Ljava/lang/Exception;
    :cond_5
    move-object v0, v1

    .end local v1           #cause:Ljava/lang/Exception;
    .restart local v0       #cause:Ljava/lang/Exception;
    goto :goto_3

    .end local v5           #writeBuffer:Ljava/util/Queue;,"Ljava/util/Queue<Lorg/jboss/netty/channel/MessageEvent;>;"
    :cond_6
    move-object v1, v0

    .end local v0           #cause:Ljava/lang/Exception;
    .restart local v1       #cause:Ljava/lang/Exception;
    goto :goto_1
.end method

.method private clearOpWrite(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V
    .locals 5
    .parameter "channel"

    .prologue
    .line 621
    iget-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    .line 622
    .local v2, selector:Ljava/nio/channels/Selector;
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getDatagramChannel()Ljava/nio/channels/DatagramChannel;

    move-result-object v3

    invoke-virtual {v3, v2}, Ljava/nio/channels/DatagramChannel;->keyFor(Ljava/nio/channels/Selector;)Ljava/nio/channels/SelectionKey;

    move-result-object v1

    .line 623
    .local v1, key:Ljava/nio/channels/SelectionKey;
    if-nez v1, :cond_0

    .line 641
    :goto_0
    return-void

    .line 626
    :cond_0
    invoke-virtual {v1}, Ljava/nio/channels/SelectionKey;->isValid()Z

    move-result v3

    if-nez v3, :cond_1

    .line 627
    invoke-direct {p0, v1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->close(Ljava/nio/channels/SelectionKey;)V

    goto :goto_0

    .line 633
    :cond_1
    iget-object v4, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->interestOpsLock:Ljava/lang/Object;

    monitor-enter v4

    .line 634
    :try_start_0
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getRawInterestOps()I

    move-result v0

    .line 635
    .local v0, interestOps:I
    and-int/lit8 v3, v0, 0x4

    if-eqz v3, :cond_2

    .line 636
    and-int/lit8 v0, v0, -0x5

    .line 637
    invoke-virtual {v1, v0}, Ljava/nio/channels/SelectionKey;->interestOps(I)Ljava/nio/channels/SelectionKey;

    .line 638
    invoke-virtual {p1, v0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->setRawInterestOpsNow(I)V

    .line 640
    :cond_2
    monitor-exit v4

    goto :goto_0

    .end local v0           #interestOps:I
    :catchall_0
    move-exception v3

    monitor-exit v4
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v3
.end method

.method private close(Ljava/nio/channels/SelectionKey;)V
    .locals 2
    .parameter "k"

    .prologue
    .line 428
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->attachment()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;

    .line 429
    .local v0, ch:Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;
    invoke-static {v0}, Lorg/jboss/netty/channel/Channels;->succeededFuture(Lorg/jboss/netty/channel/Channel;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v1

    invoke-virtual {p0, v0, v1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->close(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;Lorg/jboss/netty/channel/ChannelFuture;)V

    .line 430
    return-void
.end method

.method static disconnect(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;Lorg/jboss/netty/channel/ChannelFuture;)V
    .locals 3
    .parameter "channel"
    .parameter "future"

    .prologue
    .line 644
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->isConnected()Z

    move-result v0

    .line 646
    .local v0, connected:Z
    :try_start_0
    invoke-virtual {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getDatagramChannel()Ljava/nio/channels/DatagramChannel;

    move-result-object v2

    invoke-virtual {v2}, Ljava/nio/channels/DatagramChannel;->disconnect()Ljava/nio/channels/DatagramChannel;

    .line 647
    invoke-interface {p1}, Lorg/jboss/netty/channel/ChannelFuture;->setSuccess()Z

    .line 648
    if-eqz v0, :cond_0

    .line 649
    invoke-static {p0}, Lorg/jboss/netty/channel/Channels;->fireChannelDisconnected(Lorg/jboss/netty/channel/Channel;)V
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    .line 655
    :cond_0
    :goto_0
    return-void

    .line 651
    :catch_0
    move-exception v1

    .line 652
    .local v1, t:Ljava/lang/Throwable;
    invoke-interface {p1, v1}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z

    .line 653
    invoke-static {p0, v1}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method private processRegisterTaskQueue()V
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 310
    :goto_0
    iget-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->registerTaskQueue:Ljava/util/Queue;

    invoke-interface {v1}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Runnable;

    .line 311
    .local v0, task:Ljava/lang/Runnable;
    if-nez v0, :cond_0

    .line 318
    return-void

    .line 315
    :cond_0
    invoke-interface {v0}, Ljava/lang/Runnable;->run()V

    .line 316
    invoke-direct {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cleanUpCancelledKeys()Z

    goto :goto_0
.end method

.method private processSelectedKeys(Ljava/util/Set;)V
    .locals 5
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/Set",
            "<",
            "Ljava/nio/channels/SelectionKey;",
            ">;)V"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 336
    .local p1, selectedKeys:Ljava/util/Set;,"Ljava/util/Set<Ljava/nio/channels/SelectionKey;>;"
    invoke-interface {p1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v1

    .local v1, i:Ljava/util/Iterator;,"Ljava/util/Iterator<Ljava/nio/channels/SelectionKey;>;"
    :cond_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-eqz v4, :cond_4

    .line 337
    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/nio/channels/SelectionKey;

    .line 338
    .local v2, k:Ljava/nio/channels/SelectionKey;
    invoke-interface {v1}, Ljava/util/Iterator;->remove()V

    .line 340
    :try_start_0
    invoke-virtual {v2}, Ljava/nio/channels/SelectionKey;->readyOps()I

    move-result v3

    .line 341
    .local v3, readyOps:I
    and-int/lit8 v4, v3, 0x1

    if-nez v4, :cond_1

    if-nez v3, :cond_2

    .line 342
    :cond_1
    invoke-direct {p0, v2}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->read(Ljava/nio/channels/SelectionKey;)Z

    move-result v4

    if-eqz v4, :cond_0

    .line 347
    :cond_2
    and-int/lit8 v4, v3, 0x4

    if-eqz v4, :cond_3

    .line 348
    invoke-virtual {p0, v2}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->writeFromSelectorLoop(Ljava/nio/channels/SelectionKey;)V
    :try_end_0
    .catch Ljava/nio/channels/CancelledKeyException; {:try_start_0 .. :try_end_0} :catch_0

    .line 354
    .end local v3           #readyOps:I
    :cond_3
    :goto_0
    invoke-direct {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cleanUpCancelledKeys()Z

    move-result v4

    if-eqz v4, :cond_0

    .line 358
    .end local v2           #k:Ljava/nio/channels/SelectionKey;
    :cond_4
    return-void

    .line 350
    .restart local v2       #k:Ljava/nio/channels/SelectionKey;
    :catch_0
    move-exception v0

    .line 351
    .local v0, e:Ljava/nio/channels/CancelledKeyException;
    invoke-direct {p0, v2}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->close(Ljava/nio/channels/SelectionKey;)V

    goto :goto_0
.end method

.method private processWriteTaskQueue()V
    .locals 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 325
    :goto_0
    iget-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->writeTaskQueue:Ljava/util/Queue;

    invoke-interface {v1}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Runnable;

    .line 326
    .local v0, task:Ljava/lang/Runnable;
    if-nez v0, :cond_0

    .line 333
    return-void

    .line 330
    :cond_0
    invoke-interface {v0}, Ljava/lang/Runnable;->run()V

    .line 331
    invoke-direct {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cleanUpCancelledKeys()Z

    goto :goto_0
.end method

.method private read(Ljava/nio/channels/SelectionKey;)Z
    .locals 11
    .parameter "key"

    .prologue
    .line 377
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->attachment()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;

    .line 378
    .local v2, channel:Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;
    invoke-virtual {v2}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getConfig()Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    move-result-object v9

    invoke-interface {v9}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;->getReceiveBufferSizePredictor()Lorg/jboss/netty/channel/ReceiveBufferSizePredictor;

    move-result-object v5

    .line 380
    .local v5, predictor:Lorg/jboss/netty/channel/ReceiveBufferSizePredictor;
    invoke-virtual {v2}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getConfig()Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    move-result-object v9

    invoke-interface {v9}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;->getBufferFactory()Lorg/jboss/netty/buffer/ChannelBufferFactory;

    move-result-object v0

    .line 381
    .local v0, bufferFactory:Lorg/jboss/netty/buffer/ChannelBufferFactory;
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->channel()Ljava/nio/channels/SelectableChannel;

    move-result-object v4

    check-cast v4, Ljava/nio/channels/DatagramChannel;

    .line 387
    .local v4, nioChannel:Ljava/nio/channels/DatagramChannel;
    invoke-interface {v5}, Lorg/jboss/netty/channel/ReceiveBufferSizePredictor;->nextReceiveBufferSize()I

    move-result v9

    invoke-static {v9}, Ljava/nio/ByteBuffer;->allocate(I)Ljava/nio/ByteBuffer;

    move-result-object v9

    invoke-interface {v0}, Lorg/jboss/netty/buffer/ChannelBufferFactory;->getDefaultOrder()Ljava/nio/ByteOrder;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/nio/ByteBuffer;->order(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;

    move-result-object v1

    .line 390
    .local v1, byteBuffer:Ljava/nio/ByteBuffer;
    const/4 v3, 0x1

    .line 391
    .local v3, failure:Z
    const/4 v7, 0x0

    .line 395
    .local v7, remoteAddress:Ljava/net/SocketAddress;
    :try_start_0
    invoke-virtual {v4, v1}, Ljava/nio/channels/DatagramChannel;->receive(Ljava/nio/ByteBuffer;)Ljava/net/SocketAddress;
    :try_end_0
    .catch Ljava/nio/channels/ClosedChannelException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v7

    .line 396
    const/4 v3, 0x0

    .line 403
    :goto_0
    if-eqz v7, :cond_0

    .line 405
    invoke-virtual {v1}, Ljava/nio/ByteBuffer;->flip()Ljava/nio/Buffer;

    .line 407
    invoke-virtual {v1}, Ljava/nio/ByteBuffer;->remaining()I

    move-result v6

    .line 408
    .local v6, readBytes:I
    if-lez v6, :cond_0

    .line 410
    invoke-interface {v5, v6}, Lorg/jboss/netty/channel/ReceiveBufferSizePredictor;->previousReceiveBufferSize(I)V

    .line 413
    invoke-interface {v0, v1}, Lorg/jboss/netty/buffer/ChannelBufferFactory;->getBuffer(Ljava/nio/ByteBuffer;)Lorg/jboss/netty/buffer/ChannelBuffer;

    move-result-object v9

    invoke-static {v2, v9, v7}, Lorg/jboss/netty/channel/Channels;->fireMessageReceived(Lorg/jboss/netty/channel/Channel;Ljava/lang/Object;Ljava/net/SocketAddress;)V

    .line 418
    .end local v6           #readBytes:I
    :cond_0
    if-eqz v3, :cond_1

    .line 419
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->cancel()V

    .line 420
    invoke-static {v2}, Lorg/jboss/netty/channel/Channels;->succeededFuture(Lorg/jboss/netty/channel/Channel;)Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v9

    invoke-virtual {p0, v2, v9}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->close(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;Lorg/jboss/netty/channel/ChannelFuture;)V

    .line 421
    const/4 v9, 0x0

    .line 424
    :goto_1
    return v9

    .line 399
    :catch_0
    move-exception v8

    .line 400
    .local v8, t:Ljava/lang/Throwable;
    invoke-static {v2, v8}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    goto :goto_0

    .line 424
    .end local v8           #t:Ljava/lang/Throwable;
    :cond_1
    const/4 v9, 0x1

    goto :goto_1

    .line 397
    :catch_1
    move-exception v9

    goto :goto_0
.end method

.method private scheduleWriteIfNecessary(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)Z
    .locals 7
    .parameter "channel"

    .prologue
    const/4 v4, 0x1

    const/4 v3, 0x0

    .line 473
    iget-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->thread:Ljava/lang/Thread;

    .line 474
    .local v2, workerThread:Ljava/lang/Thread;
    if-eqz v2, :cond_0

    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v5

    if-eq v5, v2, :cond_3

    .line 475
    :cond_0
    iget-object v5, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeTaskInTaskQueue:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v5, v3, v4}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v5

    if-eqz v5, :cond_1

    .line 477
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->writeTaskQueue:Ljava/util/Queue;

    iget-object v6, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeTask:Ljava/lang/Runnable;

    invoke-interface {v5, v6}, Ljava/util/Queue;->offer(Ljava/lang/Object;)Z

    move-result v0

    .line 478
    .local v0, offered:Z
    sget-boolean v5, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->$assertionsDisabled:Z

    if-nez v5, :cond_1

    if-nez v0, :cond_1

    new-instance v3, Ljava/lang/AssertionError;

    invoke-direct {v3}, Ljava/lang/AssertionError;-><init>()V

    throw v3

    .line 481
    .end local v0           #offered:Z
    :cond_1
    iget-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    .line 482
    .local v1, selector:Ljava/nio/channels/Selector;
    if-eqz v1, :cond_2

    .line 483
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v5, v3, v4}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v3

    if-eqz v3, :cond_2

    .line 484
    invoke-virtual {v1}, Ljava/nio/channels/Selector;->wakeup()Ljava/nio/channels/Selector;

    :cond_2
    move v3, v4

    .line 490
    .end local v1           #selector:Ljava/nio/channels/Selector;
    :cond_3
    return v3
.end method

.method private setOpWrite(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V
    .locals 5
    .parameter "channel"

    .prologue
    .line 598
    iget-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    .line 599
    .local v2, selector:Ljava/nio/channels/Selector;
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getDatagramChannel()Ljava/nio/channels/DatagramChannel;

    move-result-object v3

    invoke-virtual {v3, v2}, Ljava/nio/channels/DatagramChannel;->keyFor(Ljava/nio/channels/Selector;)Ljava/nio/channels/SelectionKey;

    move-result-object v1

    .line 600
    .local v1, key:Ljava/nio/channels/SelectionKey;
    if-nez v1, :cond_0

    .line 618
    :goto_0
    return-void

    .line 603
    :cond_0
    invoke-virtual {v1}, Ljava/nio/channels/SelectionKey;->isValid()Z

    move-result v3

    if-nez v3, :cond_1

    .line 604
    invoke-direct {p0, v1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->close(Ljava/nio/channels/SelectionKey;)V

    goto :goto_0

    .line 610
    :cond_1
    iget-object v4, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->interestOpsLock:Ljava/lang/Object;

    monitor-enter v4

    .line 611
    :try_start_0
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getRawInterestOps()I

    move-result v0

    .line 612
    .local v0, interestOps:I
    and-int/lit8 v3, v0, 0x4

    if-nez v3, :cond_2

    .line 613
    or-int/lit8 v0, v0, 0x4

    .line 614
    invoke-virtual {v1, v0}, Ljava/nio/channels/SelectionKey;->interestOps(I)Ljava/nio/channels/SelectionKey;

    .line 615
    invoke-virtual {p1, v0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->setRawInterestOpsNow(I)V

    .line 617
    :cond_2
    monitor-exit v4

    goto :goto_0

    .end local v0           #interestOps:I
    :catchall_0
    move-exception v3

    monitor-exit v4
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw v3
.end method

.method private write0(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V
    .locals 23
    .parameter "channel"

    .prologue
    .line 495
    const/4 v3, 0x0

    .line 496
    .local v3, addOpWrite:Z
    const/4 v12, 0x0

    .line 498
    .local v12, removeOpWrite:Z
    const-wide/16 v17, 0x0

    .line 500
    .local v17, writtenBytes:J
    move-object/from16 v0, p0

    iget-object v13, v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->sendBufferPool:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool;

    .line 501
    .local v13, sendBufferPool:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool;
    invoke-virtual/range {p1 .. p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getDatagramChannel()Ljava/nio/channels/DatagramChannel;

    move-result-object v5

    .line 502
    .local v5, ch:Ljava/nio/channels/DatagramChannel;
    move-object/from16 v0, p1

    iget-object v15, v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeBufferQueue:Ljava/util/Queue;

    .line 503
    .local v15, writeBuffer:Ljava/util/Queue;,"Ljava/util/Queue<Lorg/jboss/netty/channel/MessageEvent;>;"
    invoke-virtual/range {p1 .. p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getConfig()Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;

    move-result-object v19

    invoke-interface/range {v19 .. v19}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannelConfig;->getWriteSpinCount()I

    move-result v16

    .line 504
    .local v16, writeSpinCount:I
    move-object/from16 v0, p1

    iget-object v0, v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeLock:Ljava/lang/Object;

    move-object/from16 v20, v0

    monitor-enter v20

    .line 506
    const/16 v19, 0x1

    :try_start_0
    move/from16 v0, v19

    move-object/from16 v1, p1

    iput-boolean v0, v1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->inWriteNowLoop:Z

    .line 510
    :goto_0
    move-object/from16 v0, p1

    iget-object v6, v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteEvent:Lorg/jboss/netty/channel/MessageEvent;

    .line 512
    .local v6, evt:Lorg/jboss/netty/channel/MessageEvent;
    if-nez v6, :cond_4

    .line 513
    invoke-interface {v15}, Ljava/util/Queue;->poll()Ljava/lang/Object;

    move-result-object v6

    .end local v6           #evt:Lorg/jboss/netty/channel/MessageEvent;
    check-cast v6, Lorg/jboss/netty/channel/MessageEvent;

    .restart local v6       #evt:Lorg/jboss/netty/channel/MessageEvent;
    move-object/from16 v0, p1

    iput-object v6, v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteEvent:Lorg/jboss/netty/channel/MessageEvent;

    if-nez v6, :cond_1

    .line 514
    const/4 v12, 0x1

    .line 515
    const/16 v19, 0x0

    move/from16 v0, v19

    move-object/from16 v1, p1

    iput-boolean v0, v1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeSuspended:Z

    .line 579
    :goto_1
    const/16 v19, 0x0

    move/from16 v0, v19

    move-object/from16 v1, p1

    iput-boolean v0, v1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->inWriteNowLoop:Z

    .line 587
    if-eqz v3, :cond_9

    .line 588
    invoke-direct/range {p0 .. p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->setOpWrite(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V

    .line 592
    :cond_0
    :goto_2
    monitor-exit v20
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 594
    move-object/from16 v0, p1

    move-wide/from16 v1, v17

    invoke-static {v0, v1, v2}, Lorg/jboss/netty/channel/Channels;->fireWriteComplete(Lorg/jboss/netty/channel/Channel;J)V

    .line 595
    return-void

    .line 519
    :cond_1
    :try_start_1
    invoke-interface {v6}, Lorg/jboss/netty/channel/MessageEvent;->getMessage()Ljava/lang/Object;

    move-result-object v19

    move-object/from16 v0, v19

    invoke-virtual {v13, v0}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool;->acquire(Ljava/lang/Object;)Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;

    move-result-object v4

    .local v4, buf:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;
    move-object/from16 v0, p1

    iput-object v4, v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteBuffer:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 525
    :goto_3
    const-wide/16 v9, 0x0

    .line 526
    .local v9, localWrittenBytes:J
    :try_start_2
    invoke-interface {v6}, Lorg/jboss/netty/channel/MessageEvent;->getRemoteAddress()Ljava/net/SocketAddress;

    move-result-object v11

    .line 527
    .local v11, raddr:Ljava/net/SocketAddress;
    if-nez v11, :cond_6

    .line 528
    move/from16 v8, v16

    .local v8, i:I
    :goto_4
    if-lez v8, :cond_2

    .line 529
    invoke-interface {v4, v5}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;->transferTo(Ljava/nio/channels/WritableByteChannel;)J

    move-result-wide v9

    .line 530
    const-wide/16 v21, 0x0

    cmp-long v19, v9, v21

    if-eqz v19, :cond_5

    .line 531
    add-long v17, v17, v9

    .line 551
    :cond_2
    :goto_5
    const-wide/16 v21, 0x0

    cmp-long v19, v9, v21

    if-gtz v19, :cond_3

    invoke-interface {v4}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;->finished()Z

    move-result v19

    if-eqz v19, :cond_8

    .line 553
    :cond_3
    invoke-interface {v4}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;->release()V

    .line 554
    invoke-interface {v6}, Lorg/jboss/netty/channel/MessageEvent;->getFuture()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v7

    .line 555
    .local v7, future:Lorg/jboss/netty/channel/ChannelFuture;
    const/16 v19, 0x0

    move-object/from16 v0, v19

    move-object/from16 v1, p1

    iput-object v0, v1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteEvent:Lorg/jboss/netty/channel/MessageEvent;

    .line 556
    const/16 v19, 0x0

    move-object/from16 v0, v19

    move-object/from16 v1, p1

    iput-object v0, v1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteBuffer:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;

    .line 557
    const/4 v6, 0x0

    .line 558
    const/4 v4, 0x0

    .line 559
    invoke-interface {v7}, Lorg/jboss/netty/channel/ChannelFuture;->setSuccess()Z
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0
    .catch Ljava/nio/channels/AsynchronousCloseException; {:try_start_2 .. :try_end_2} :catch_0
    .catch Ljava/lang/Throwable; {:try_start_2 .. :try_end_2} :catch_1

    goto :goto_0

    .line 566
    .end local v7           #future:Lorg/jboss/netty/channel/ChannelFuture;
    .end local v8           #i:I
    .end local v11           #raddr:Ljava/net/SocketAddress;
    :catch_0
    move-exception v19

    goto/16 :goto_0

    .line 521
    .end local v4           #buf:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;
    .end local v9           #localWrittenBytes:J
    :cond_4
    :try_start_3
    move-object/from16 v0, p1

    iget-object v4, v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteBuffer:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .restart local v4       #buf:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;
    goto :goto_3

    .line 534
    .restart local v8       #i:I
    .restart local v9       #localWrittenBytes:J
    .restart local v11       #raddr:Ljava/net/SocketAddress;
    :cond_5
    :try_start_4
    invoke-interface {v4}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;->finished()Z

    move-result v19

    if-nez v19, :cond_2

    .line 528
    add-int/lit8 v8, v8, -0x1

    goto :goto_4

    .line 539
    .end local v8           #i:I
    :cond_6
    move/from16 v8, v16

    .restart local v8       #i:I
    :goto_6
    if-lez v8, :cond_2

    .line 540
    invoke-interface {v4, v5, v11}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;->transferTo(Ljava/nio/channels/DatagramChannel;Ljava/net/SocketAddress;)J

    move-result-wide v9

    .line 541
    const-wide/16 v21, 0x0

    cmp-long v19, v9, v21

    if-eqz v19, :cond_7

    .line 542
    add-long v17, v17, v9

    .line 543
    goto :goto_5

    .line 545
    :cond_7
    invoke-interface {v4}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;->finished()Z

    move-result v19

    if-nez v19, :cond_2

    .line 539
    add-int/lit8 v8, v8, -0x1

    goto :goto_6

    .line 562
    :cond_8
    const/4 v3, 0x1

    .line 563
    const/16 v19, 0x1

    move/from16 v0, v19

    move-object/from16 v1, p1

    iput-boolean v0, v1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeSuspended:Z
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0
    .catch Ljava/nio/channels/AsynchronousCloseException; {:try_start_4 .. :try_end_4} :catch_0
    .catch Ljava/lang/Throwable; {:try_start_4 .. :try_end_4} :catch_1

    goto/16 :goto_1

    .line 568
    .end local v8           #i:I
    .end local v11           #raddr:Ljava/net/SocketAddress;
    :catch_1
    move-exception v14

    .line 569
    .local v14, t:Ljava/lang/Throwable;
    :try_start_5
    invoke-interface {v4}, Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;->release()V

    .line 570
    invoke-interface {v6}, Lorg/jboss/netty/channel/MessageEvent;->getFuture()Lorg/jboss/netty/channel/ChannelFuture;

    move-result-object v7

    .line 571
    .restart local v7       #future:Lorg/jboss/netty/channel/ChannelFuture;
    const/16 v19, 0x0

    move-object/from16 v0, v19

    move-object/from16 v1, p1

    iput-object v0, v1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteEvent:Lorg/jboss/netty/channel/MessageEvent;

    .line 572
    const/16 v19, 0x0

    move-object/from16 v0, v19

    move-object/from16 v1, p1

    iput-object v0, v1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->currentWriteBuffer:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;

    .line 573
    const/4 v4, 0x0

    .line 574
    const/4 v6, 0x0

    .line 575
    invoke-interface {v7, v14}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z

    .line 576
    move-object/from16 v0, p1

    invoke-static {v0, v14}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    goto/16 :goto_0

    .line 592
    .end local v4           #buf:Lorg/jboss/netty/channel/socket/nio/SocketSendBufferPool$SendBuffer;
    .end local v6           #evt:Lorg/jboss/netty/channel/MessageEvent;
    .end local v7           #future:Lorg/jboss/netty/channel/ChannelFuture;
    .end local v9           #localWrittenBytes:J
    .end local v14           #t:Ljava/lang/Throwable;
    :catchall_0
    move-exception v19

    monitor-exit v20
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    throw v19

    .line 589
    .restart local v6       #evt:Lorg/jboss/netty/channel/MessageEvent;
    :cond_9
    if-eqz v12, :cond_0

    .line 590
    :try_start_6
    invoke-direct/range {p0 .. p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->clearOpWrite(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_0

    goto/16 :goto_2
.end method


# virtual methods
.method close(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;Lorg/jboss/netty/channel/ChannelFuture;)V
    .locals 4
    .parameter "channel"
    .parameter "future"

    .prologue
    .line 659
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->isConnected()Z

    move-result v1

    .line 660
    .local v1, connected:Z
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->isBound()Z

    move-result v0

    .line 662
    .local v0, bound:Z
    :try_start_0
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getDatagramChannel()Ljava/nio/channels/DatagramChannel;

    move-result-object v3

    invoke-virtual {v3}, Ljava/nio/channels/DatagramChannel;->close()V

    .line 663
    iget v3, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cancelledKeys:I

    add-int/lit8 v3, v3, 0x1

    iput v3, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cancelledKeys:I

    .line 665
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->setClosed()Z

    move-result v3

    if-eqz v3, :cond_2

    .line 666
    invoke-interface {p2}, Lorg/jboss/netty/channel/ChannelFuture;->setSuccess()Z

    .line 667
    if-eqz v1, :cond_0

    .line 668
    invoke-static {p1}, Lorg/jboss/netty/channel/Channels;->fireChannelDisconnected(Lorg/jboss/netty/channel/Channel;)V

    .line 670
    :cond_0
    if-eqz v0, :cond_1

    .line 671
    invoke-static {p1}, Lorg/jboss/netty/channel/Channels;->fireChannelUnbound(Lorg/jboss/netty/channel/Channel;)V

    .line 674
    :cond_1
    invoke-direct {p0, p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cleanUpWriteBuffer(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V

    .line 675
    invoke-static {p1}, Lorg/jboss/netty/channel/Channels;->fireChannelClosed(Lorg/jboss/netty/channel/Channel;)V

    .line 683
    :goto_0
    return-void

    .line 677
    :cond_2
    invoke-interface {p2}, Lorg/jboss/netty/channel/ChannelFuture;->setSuccess()Z
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 679
    :catch_0
    move-exception v2

    .line 680
    .local v2, t:Ljava/lang/Throwable;
    invoke-interface {p2, v2}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z

    .line 681
    invoke-static {p1, v2}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method register(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;Lorg/jboss/netty/channel/ChannelFuture;)V
    .locals 11
    .parameter "channel"
    .parameter "future"

    .prologue
    const/4 v10, 0x1

    .line 148
    new-instance v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker$ChannelRegistionTask;

    invoke-direct {v0, p0, p1, p2}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker$ChannelRegistionTask;-><init>(Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;Lorg/jboss/netty/channel/ChannelFuture;)V

    .line 152
    .local v0, channelRegTask:Ljava/lang/Runnable;
    iget-object v6, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->startStopLock:Ljava/lang/Object;

    monitor-enter v6

    .line 153
    :try_start_0
    iget-boolean v5, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->started:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-nez v5, :cond_3

    .line 156
    :try_start_1
    invoke-static {}, Ljava/nio/channels/Selector;->open()Ljava/nio/channels/Selector;

    move-result-object v2

    .local v2, selector:Ljava/nio/channels/Selector;
    iput-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_0

    .line 162
    const/4 v3, 0x0

    .line 165
    .local v3, success:Z
    :try_start_2
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->executor:Ljava/util/concurrent/Executor;

    new-instance v7, Lorg/jboss/netty/util/ThreadRenamingRunnable;

    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    const-string v9, "New I/O datagram worker #"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    iget v9, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->bossId:I

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "\'-\'"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    iget v9, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->id:I

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    invoke-direct {v7, p0, v8}, Lorg/jboss/netty/util/ThreadRenamingRunnable;-><init>(Ljava/lang/Runnable;Ljava/lang/String;)V

    invoke-interface {v5, v7}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1

    .line 167
    const/4 v3, 0x1

    .line 169
    if-nez v3, :cond_0

    .line 172
    :try_start_3
    invoke-virtual {v2}, Ljava/nio/channels/Selector;->close()V
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0
    .catch Ljava/lang/Throwable; {:try_start_3 .. :try_end_3} :catch_1

    .line 176
    :goto_0
    const/4 v2, 0x0

    :try_start_4
    iput-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    .line 184
    .end local v3           #success:Z
    :cond_0
    :goto_1
    sget-boolean v5, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->$assertionsDisabled:Z

    if-nez v5, :cond_4

    if-eqz v2, :cond_1

    invoke-virtual {v2}, Ljava/nio/channels/Selector;->isOpen()Z

    move-result v5

    if-nez v5, :cond_4

    :cond_1
    new-instance v5, Ljava/lang/AssertionError;

    invoke-direct {v5}, Ljava/lang/AssertionError;-><init>()V

    throw v5

    .line 191
    .end local v2           #selector:Ljava/nio/channels/Selector;
    :catchall_0
    move-exception v5

    monitor-exit v6
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    throw v5

    .line 157
    :catch_0
    move-exception v4

    .line 158
    .local v4, t:Ljava/lang/Throwable;
    :try_start_5
    new-instance v5, Lorg/jboss/netty/channel/ChannelException;

    const-string v7, "Failed to create a selector."

    invoke-direct {v5, v7, v4}, Lorg/jboss/netty/channel/ChannelException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v5

    .line 173
    .end local v4           #t:Ljava/lang/Throwable;
    .restart local v2       #selector:Ljava/nio/channels/Selector;
    .restart local v3       #success:Z
    :catch_1
    move-exception v4

    .line 174
    .restart local v4       #t:Ljava/lang/Throwable;
    sget-object v5, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->logger:Lorg/jboss/netty/logging/InternalLogger;

    const-string v7, "Failed to close a selector."

    invoke-interface {v5, v7, v4}, Lorg/jboss/netty/logging/InternalLogger;->warn(Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    goto :goto_0

    .line 169
    .end local v4           #t:Ljava/lang/Throwable;
    :catchall_1
    move-exception v5

    if-nez v3, :cond_2

    .line 172
    :try_start_6
    invoke-virtual {v2}, Ljava/nio/channels/Selector;->close()V
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_0
    .catch Ljava/lang/Throwable; {:try_start_6 .. :try_end_6} :catch_2

    .line 176
    :goto_2
    const/4 v2, 0x0

    :try_start_7
    iput-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    :cond_2
    throw v5

    .line 173
    :catch_2
    move-exception v4

    .line 174
    .restart local v4       #t:Ljava/lang/Throwable;
    sget-object v7, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->logger:Lorg/jboss/netty/logging/InternalLogger;

    const-string v8, "Failed to close a selector."

    invoke-interface {v7, v8, v4}, Lorg/jboss/netty/logging/InternalLogger;->warn(Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_2

    .line 182
    .end local v2           #selector:Ljava/nio/channels/Selector;
    .end local v3           #success:Z
    .end local v4           #t:Ljava/lang/Throwable;
    :cond_3
    iget-object v2, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    .restart local v2       #selector:Ljava/nio/channels/Selector;
    goto :goto_1

    .line 186
    :cond_4
    const/4 v5, 0x1

    iput-boolean v5, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->started:Z

    .line 189
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->registerTaskQueue:Ljava/util/Queue;

    invoke-interface {v5, v0}, Ljava/util/Queue;->offer(Ljava/lang/Object;)Z

    move-result v1

    .line 190
    .local v1, offered:Z
    sget-boolean v5, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->$assertionsDisabled:Z

    if-nez v5, :cond_5

    if-nez v1, :cond_5

    new-instance v5, Ljava/lang/AssertionError;

    invoke-direct {v5}, Ljava/lang/AssertionError;-><init>()V

    throw v5

    .line 191
    :cond_5
    monitor-exit v6
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_0

    .line 193
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v6, 0x0

    invoke-virtual {v5, v6, v10}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v5

    if-eqz v5, :cond_6

    .line 194
    invoke-virtual {v2}, Ljava/nio/channels/Selector;->wakeup()Ljava/nio/channels/Selector;

    .line 196
    :cond_6
    return-void
.end method

.method public run()V
    .locals 8

    .prologue
    const/4 v7, 0x0

    .line 203
    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v4

    iput-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->thread:Ljava/lang/Thread;

    .line 205
    iget-object v1, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    .line 206
    .local v1, selector:Ljava/nio/channels/Selector;
    const/4 v2, 0x0

    .line 209
    .local v2, shutdown:Z
    :goto_0
    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v4, v7}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    .line 211
    sget v4, Lorg/jboss/netty/channel/socket/nio/NioProviderMetadata;->CONSTRAINT_LEVEL:I

    if-eqz v4, :cond_0

    .line 212
    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selectorGuard:Ljava/util/concurrent/locks/ReadWriteLock;

    invoke-interface {v4}, Ljava/util/concurrent/locks/ReadWriteLock;->writeLock()Ljava/util/concurrent/locks/Lock;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/concurrent/locks/Lock;->lock()V

    .line 214
    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selectorGuard:Ljava/util/concurrent/locks/ReadWriteLock;

    invoke-interface {v4}, Ljava/util/concurrent/locks/ReadWriteLock;->writeLock()Ljava/util/concurrent/locks/Lock;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/concurrent/locks/Lock;->unlock()V

    .line 218
    :cond_0
    :try_start_0
    invoke-static {v1}, Lorg/jboss/netty/channel/socket/nio/SelectorUtil;->select(Ljava/nio/channels/Selector;)V

    .line 248
    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    invoke-virtual {v4}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z

    move-result v4

    if-eqz v4, :cond_1

    .line 249
    invoke-virtual {v1}, Ljava/nio/channels/Selector;->wakeup()Ljava/nio/channels/Selector;

    .line 252
    :cond_1
    const/4 v4, 0x0

    iput v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cancelledKeys:I

    .line 253
    invoke-direct {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->processRegisterTaskQueue()V

    .line 254
    invoke-direct {p0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->processWriteTaskQueue()V

    .line 255
    invoke-virtual {v1}, Ljava/nio/channels/Selector;->selectedKeys()Ljava/util/Set;

    move-result-object v4

    invoke-direct {p0, v4}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->processSelectedKeys(Ljava/util/Set;)V

    .line 263
    invoke-virtual {v1}, Ljava/nio/channels/Selector;->keys()Ljava/util/Set;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/Set;->isEmpty()Z

    move-result v4

    if-eqz v4, :cond_5

    .line 264
    if-nez v2, :cond_2

    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->executor:Ljava/util/concurrent/Executor;

    instance-of v4, v4, Ljava/util/concurrent/ExecutorService;

    if-eqz v4, :cond_4

    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->executor:Ljava/util/concurrent/Executor;

    check-cast v4, Ljava/util/concurrent/ExecutorService;

    invoke-interface {v4}, Ljava/util/concurrent/ExecutorService;->isShutdown()Z

    move-result v4

    if-eqz v4, :cond_4

    .line 266
    :cond_2
    iget-object v5, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->startStopLock:Ljava/lang/Object;

    monitor-enter v5
    :try_end_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_1

    .line 267
    :try_start_1
    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->registerTaskQueue:Ljava/util/Queue;

    invoke-interface {v4}, Ljava/util/Queue;->isEmpty()Z

    move-result v4

    if-eqz v4, :cond_3

    invoke-virtual {v1}, Ljava/nio/channels/Selector;->keys()Ljava/util/Set;

    move-result-object v4

    invoke-interface {v4}, Ljava/util/Set;->isEmpty()Z

    move-result v4

    if-eqz v4, :cond_3

    .line 269
    const/4 v4, 0x0

    iput-boolean v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->started:Z
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 271
    :try_start_2
    invoke-virtual {v1}, Ljava/nio/channels/Selector;->close()V
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_1
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_0

    .line 276
    const/4 v4, 0x0

    :try_start_3
    iput-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    .line 278
    :goto_1
    monitor-exit v5
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 302
    return-void

    .line 272
    :catch_0
    move-exception v0

    .line 273
    .local v0, e:Ljava/io/IOException;
    :try_start_4
    sget-object v4, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->logger:Lorg/jboss/netty/logging/InternalLogger;

    const-string v6, "Failed to close a selector."

    invoke-interface {v4, v6, v0}, Lorg/jboss/netty/logging/InternalLogger;->warn(Ljava/lang/String;Ljava/lang/Throwable;)V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    .line 276
    const/4 v4, 0x0

    :try_start_5
    iput-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    goto :goto_1

    .line 282
    .end local v0           #e:Ljava/io/IOException;
    :catchall_0
    move-exception v4

    monitor-exit v5
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    :try_start_6
    throw v4
    :try_end_6
    .catch Ljava/lang/Throwable; {:try_start_6 .. :try_end_6} :catch_1

    .line 290
    :catch_1
    move-exception v3

    .line 291
    .local v3, t:Ljava/lang/Throwable;
    sget-object v4, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->logger:Lorg/jboss/netty/logging/InternalLogger;

    const-string v5, "Unexpected exception in the selector loop."

    invoke-interface {v4, v5, v3}, Lorg/jboss/netty/logging/InternalLogger;->warn(Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 296
    const-wide/16 v4, 0x3e8

    :try_start_7
    invoke-static {v4, v5}, Ljava/lang/Thread;->sleep(J)V
    :try_end_7
    .catch Ljava/lang/InterruptedException; {:try_start_7 .. :try_end_7} :catch_2

    goto/16 :goto_0

    .line 297
    :catch_2
    move-exception v4

    goto/16 :goto_0

    .line 276
    .end local v3           #t:Ljava/lang/Throwable;
    :catchall_1
    move-exception v4

    const/4 v6, 0x0

    :try_start_8
    iput-object v6, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    throw v4

    .line 280
    :cond_3
    const/4 v2, 0x0

    .line 282
    monitor-exit v5
    :try_end_8
    .catchall {:try_start_8 .. :try_end_8} :catchall_0

    goto/16 :goto_0

    .line 285
    :cond_4
    const/4 v2, 0x1

    goto/16 :goto_0

    .line 288
    :cond_5
    const/4 v2, 0x0

    goto/16 :goto_0
.end method

.method setInterestOps(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;Lorg/jboss/netty/channel/ChannelFuture;I)V
    .locals 10
    .parameter "channel"
    .parameter "future"
    .parameter "interestOps"

    .prologue
    .line 741
    const/4 v1, 0x0

    .line 745
    .local v1, changed:Z
    :try_start_0
    iget-object v7, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->interestOpsLock:Ljava/lang/Object;

    monitor-enter v7
    :try_end_0
    .catch Ljava/nio/channels/CancelledKeyException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_1

    .line 746
    :try_start_1
    iget-object v4, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selector:Ljava/nio/channels/Selector;

    .line 747
    .local v4, selector:Ljava/nio/channels/Selector;
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getDatagramChannel()Ljava/nio/channels/DatagramChannel;

    move-result-object v6

    invoke-virtual {v6, v4}, Ljava/nio/channels/DatagramChannel;->keyFor(Ljava/nio/channels/Selector;)Ljava/nio/channels/SelectionKey;

    move-result-object v3

    .line 749
    .local v3, key:Ljava/nio/channels/SelectionKey;
    if-eqz v3, :cond_0

    if-nez v4, :cond_2

    .line 752
    :cond_0
    invoke-virtual {p1, p3}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->setRawInterestOpsNow(I)V

    .line 753
    monitor-exit v7

    .line 820
    .end local v3           #key:Ljava/nio/channels/SelectionKey;
    .end local v4           #selector:Ljava/nio/channels/Selector;
    :cond_1
    :goto_0
    return-void

    .line 757
    .restart local v3       #key:Ljava/nio/channels/SelectionKey;
    .restart local v4       #selector:Ljava/nio/channels/Selector;
    :cond_2
    and-int/lit8 p3, p3, -0x5

    .line 758
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getRawInterestOps()I

    move-result v6

    and-int/lit8 v6, v6, 0x4

    or-int/2addr p3, v6

    .line 760
    sget v6, Lorg/jboss/netty/channel/socket/nio/NioProviderMetadata;->CONSTRAINT_LEVEL:I

    packed-switch v6, :pswitch_data_0

    .line 800
    new-instance v6, Ljava/lang/Error;

    invoke-direct {v6}, Ljava/lang/Error;-><init>()V

    throw v6

    .line 805
    .end local v3           #key:Ljava/nio/channels/SelectionKey;
    .end local v4           #selector:Ljava/nio/channels/Selector;
    :catchall_0
    move-exception v6

    monitor-exit v7
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    :try_start_2
    throw v6
    :try_end_2
    .catch Ljava/nio/channels/CancelledKeyException; {:try_start_2 .. :try_end_2} :catch_0
    .catch Ljava/lang/Throwable; {:try_start_2 .. :try_end_2} :catch_1

    .line 811
    :catch_0
    move-exception v2

    .line 813
    .local v2, e:Ljava/nio/channels/CancelledKeyException;
    new-instance v0, Ljava/nio/channels/ClosedChannelException;

    invoke-direct {v0}, Ljava/nio/channels/ClosedChannelException;-><init>()V

    .line 814
    .local v0, cce:Ljava/nio/channels/ClosedChannelException;
    invoke-interface {p2, v0}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z

    .line 815
    invoke-static {p1, v0}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    goto :goto_0

    .line 762
    .end local v0           #cce:Ljava/nio/channels/ClosedChannelException;
    .end local v2           #e:Ljava/nio/channels/CancelledKeyException;
    .restart local v3       #key:Ljava/nio/channels/SelectionKey;
    .restart local v4       #selector:Ljava/nio/channels/Selector;
    :pswitch_0
    :try_start_3
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getRawInterestOps()I

    move-result v6

    if-eq v6, p3, :cond_4

    .line 764
    invoke-virtual {v3, p3}, Ljava/nio/channels/SelectionKey;->interestOps(I)Ljava/nio/channels/SelectionKey;

    .line 768
    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v6

    iget-object v8, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->thread:Ljava/lang/Thread;

    if-eq v6, v8, :cond_3

    iget-object v6, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v8, 0x0

    const/4 v9, 0x1

    invoke-virtual {v6, v8, v9}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v6

    if-eqz v6, :cond_3

    .line 770
    invoke-virtual {v4}, Ljava/nio/channels/Selector;->wakeup()Ljava/nio/channels/Selector;

    .line 772
    :cond_3
    const/4 v1, 0x1

    .line 802
    :cond_4
    :goto_1
    if-eqz v1, :cond_5

    .line 803
    invoke-virtual {p1, p3}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->setRawInterestOpsNow(I)V

    .line 805
    :cond_5
    monitor-exit v7
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 807
    :try_start_4
    invoke-interface {p2}, Lorg/jboss/netty/channel/ChannelFuture;->setSuccess()Z

    .line 808
    if-eqz v1, :cond_1

    .line 809
    invoke-static {p1}, Lorg/jboss/netty/channel/Channels;->fireChannelInterestChanged(Lorg/jboss/netty/channel/Channel;)V
    :try_end_4
    .catch Ljava/nio/channels/CancelledKeyException; {:try_start_4 .. :try_end_4} :catch_0
    .catch Ljava/lang/Throwable; {:try_start_4 .. :try_end_4} :catch_1

    goto :goto_0

    .line 816
    .end local v3           #key:Ljava/nio/channels/SelectionKey;
    .end local v4           #selector:Ljava/nio/channels/Selector;
    :catch_1
    move-exception v5

    .line 817
    .local v5, t:Ljava/lang/Throwable;
    invoke-interface {p2, v5}, Lorg/jboss/netty/channel/ChannelFuture;->setFailure(Ljava/lang/Throwable;)Z

    .line 818
    invoke-static {p1, v5}, Lorg/jboss/netty/channel/Channels;->fireExceptionCaught(Lorg/jboss/netty/channel/Channel;Ljava/lang/Throwable;)V

    goto :goto_0

    .line 777
    .end local v5           #t:Ljava/lang/Throwable;
    .restart local v3       #key:Ljava/nio/channels/SelectionKey;
    .restart local v4       #selector:Ljava/nio/channels/Selector;
    :pswitch_1
    :try_start_5
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->getRawInterestOps()I

    move-result v6

    if-eq v6, p3, :cond_4

    .line 778
    invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;

    move-result-object v6

    iget-object v8, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->thread:Ljava/lang/Thread;

    if-ne v6, v8, :cond_6

    .line 781
    invoke-virtual {v3, p3}, Ljava/nio/channels/SelectionKey;->interestOps(I)Ljava/nio/channels/SelectionKey;

    .line 782
    const/4 v1, 0x1

    goto :goto_1

    .line 786
    :cond_6
    iget-object v6, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selectorGuard:Ljava/util/concurrent/locks/ReadWriteLock;

    invoke-interface {v6}, Ljava/util/concurrent/locks/ReadWriteLock;->readLock()Ljava/util/concurrent/locks/Lock;

    move-result-object v6

    invoke-interface {v6}, Ljava/util/concurrent/locks/Lock;->lock()V
    :try_end_5
    .catchall {:try_start_5 .. :try_end_5} :catchall_0

    .line 788
    :try_start_6
    iget-object v6, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->wakenUp:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v8, 0x0

    const/4 v9, 0x1

    invoke-virtual {v6, v8, v9}, Ljava/util/concurrent/atomic/AtomicBoolean;->compareAndSet(ZZ)Z

    move-result v6

    if-eqz v6, :cond_7

    .line 789
    invoke-virtual {v4}, Ljava/nio/channels/Selector;->wakeup()Ljava/nio/channels/Selector;

    .line 791
    :cond_7
    invoke-virtual {v3, p3}, Ljava/nio/channels/SelectionKey;->interestOps(I)Ljava/nio/channels/SelectionKey;
    :try_end_6
    .catchall {:try_start_6 .. :try_end_6} :catchall_1

    .line 792
    const/4 v1, 0x1

    .line 794
    :try_start_7
    iget-object v6, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selectorGuard:Ljava/util/concurrent/locks/ReadWriteLock;

    invoke-interface {v6}, Ljava/util/concurrent/locks/ReadWriteLock;->readLock()Ljava/util/concurrent/locks/Lock;

    move-result-object v6

    invoke-interface {v6}, Ljava/util/concurrent/locks/Lock;->unlock()V

    goto :goto_1

    :catchall_1
    move-exception v6

    iget-object v8, p0, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->selectorGuard:Ljava/util/concurrent/locks/ReadWriteLock;

    invoke-interface {v8}, Ljava/util/concurrent/locks/ReadWriteLock;->readLock()Ljava/util/concurrent/locks/Lock;

    move-result-object v8

    invoke-interface {v8}, Ljava/util/concurrent/locks/Lock;->unlock()V

    throw v6
    :try_end_7
    .catchall {:try_start_7 .. :try_end_7} :catchall_0

    .line 760
    nop

    :pswitch_data_0
    .packed-switch 0x0
        :pswitch_0
        :pswitch_1
        :pswitch_1
    .end packed-switch
.end method

.method writeFromSelectorLoop(Ljava/nio/channels/SelectionKey;)V
    .locals 2
    .parameter "k"

    .prologue
    .line 467
    invoke-virtual {p1}, Ljava/nio/channels/SelectionKey;->attachment()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;

    .line 468
    .local v0, ch:Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;
    const/4 v1, 0x0

    iput-boolean v1, v0, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeSuspended:Z

    .line 469
    invoke-direct {p0, v0}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->write0(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V

    .line 470
    return-void
.end method

.method writeFromTaskLoop(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V
    .locals 1
    .parameter "ch"

    .prologue
    .line 461
    iget-boolean v0, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeSuspended:Z

    if-nez v0, :cond_0

    .line 462
    invoke-direct {p0, p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->write0(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V

    .line 464
    :cond_0
    return-void
.end method

.method writeFromUserCode(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V
    .locals 1
    .parameter "channel"

    .prologue
    .line 438
    invoke-virtual {p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->isBound()Z

    move-result v0

    if-nez v0, :cond_1

    .line 439
    invoke-direct {p0, p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->cleanUpWriteBuffer(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V

    .line 458
    :cond_0
    :goto_0
    return-void

    .line 443
    :cond_1
    invoke-direct {p0, p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->scheduleWriteIfNecessary(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)Z

    move-result v0

    if-nez v0, :cond_0

    .line 449
    iget-boolean v0, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->writeSuspended:Z

    if-nez v0, :cond_0

    .line 453
    iget-boolean v0, p1, Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;->inWriteNowLoop:Z

    if-nez v0, :cond_0

    .line 457
    invoke-direct {p0, p1}, Lorg/jboss/netty/channel/socket/nio/NioDatagramWorker;->write0(Lorg/jboss/netty/channel/socket/nio/NioDatagramChannel;)V

    goto :goto_0
.end method
